//
//  thirPersonSecCell.m
//  HappyStore
//
//  Created by 陈锋 on 16/6/14.
//  Copyright © 2016年 LLJ. All rights reserved.
//

#import "thirPersonSecCell.h"

@implementation thirPersonSecCell


+ (instancetype)cellWithTableView:(UITableView *)tableView{
    
    static NSString *identifier = @"status";

    
    thirPersonSecCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    
    if (cell == nil) {
        cell = [[thirPersonSecCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
     }
    return cell;
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    _mtArr = [NSMutableArray array];

    
    if (self) {
        NSArray * labelText = @[@"项目",@"资金",@"活动",@"招聘",@"服务"];
        for (int i = 0; i < labelText.count; i++) {
            
//            创建按钮
            UIButton * button = [[UIButton alloc]initWithFrame:CGRectMake(i%5*self.width/5, 0, self.width/5, self.height)];
            button.tag = i;
            [button addTarget:self action:@selector(clickButton:) forControlEvents:UIControlEventTouchUpInside];
            [self.contentView addSubview:button];

            
            UILabel * bottomLabel = [[UILabel alloc]initWithFrame:CGRectMake(i%5*self.width/5, self.height/2 - 10, self.width/5, 60)];

            bottomLabel.backgroundColor = [UIColor clearColor];
            bottomLabel.textAlignment = NSTextAlignmentCenter;
            //bottomLabel.font = [UIFont fontWithName:@"黑体-简" size:10];
            bottomLabel.font = [UIFont systemFontOfSize:16];
            bottomLabel.textColor = [UIColor colorWithRed:0.0/255.0f green:180.0/255.0f blue:222.0/255.0f alpha:1.0f];
            [self.contentView addSubview:bottomLabel];
            [_mtArr addObject:bottomLabel];

            
            //创建文本
            UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(i%5*self.width/5, i/5+10, self.width/5, self.height/2)];
            label.text = labelText[i];
            label.backgroundColor = [UIColor clearColor];
            label.textAlignment = NSTextAlignmentCenter;
            //label.font = [UIFont fontWithName:@"黑体-简" size:10];
            label.font = [UIFont systemFontOfSize:16];
            label.textColor = RGB(117, 117, 117);
            [self.contentView addSubview:label];
            
            //创建竖线
            UIView *view = [[UIView alloc] initWithFrame:CGRectMake(i%5*self.width/5 +65, i/5+13, 0.5, 36)];
            view.backgroundColor = RGB(235, 235, 235);
            [self.contentView addSubview:view];
        }

    }
    
    
    return self;
}

//按钮事件方法
-(void)clickButton:(UIButton *)button{
    NSLog(@"%ld",(long)button.tag);
    NSString * category = @"项目";
    switch (button.tag) {
        case 1:
            category = @"资金";
            break;
        case 2:
            category = @"活动";
            break;
        case 3:
            category = @"招聘";
            break;
        case 4:
            category = @"服务";
            break;
            
        default:
            break;
    }
    
    //发送一条通知给MainTableViewController
    [[NSNotificationCenter defaultCenter]postNotificationName:@"clicktThirPerson" object:nil userInfo:@{@"category":category}];
}

@end
